<%@page import="helpers.UrlHelper"%>
<%@page import="java.util.List"%>
<%@page import="entities.DomainIp"%>
<%@page import="entities.Domain"%>
<%@page import="entities.IpAddress"%>
<%
String name = (String) request.getAttribute("name");
Domain domain = (Domain) request.getAttribute("domain");
IpAddress ipAddress = (IpAddress) request.getAttribute("ipAddress");
DomainIp domainIp = (DomainIp) request.getAttribute("domainIp");

//Set content for seo
String title = "Ip Information for " + name;
String description = "" ;
if (domain != null && !domain.getIp().isEmpty()) {
	description = "Domain " + domain.getDomain() + " has ip address is " + domain.getIp();
} else {
	description = "Can't found Ip Address for " + name;
}
String keywords = name + ",domain ip,same ip,same domain,lookup,trace,ip,ip address,ip geo,my ip,my ip address,check ip address,find ip,find domain ip,ip location";
String url = UrlHelper.getServerUrl(request) + "/domain/" + name;

%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<jsp:include page="/layouts/header.jsp">
	<jsp:param name="title" value="<%=title %>" />
    <jsp:param name="description" value="<%=description %>" />
    <jsp:param name="keywords" value="<%=keywords %>" />
    <jsp:param name="ogtitle" value="<%=title %>" />
    <jsp:param name="ogurl" value="<%=url %>" />
    <jsp:param name="ogdescription" value="<%=description%>" />
</jsp:include>

	<script type="text/javascript" src="/js/domain.js"></script>
	
	<div class="row">
		<div class="span9">
			<div class="search-box">
				<div class="row">
					<div class="span3">
						<h4>Get IP Address</h4>
					</div>
					<div class="span6">
						<form class="form-search" action="/goto" method="get">
							<div class="input-append">
							    <input type="text" class="span2 search-query input-xxlarge" name="q" placeholder="<%=domain != null ? domain.getDomain() : "ex: google.com"%>">
							    <button type="submit" class="btn">Search</button>
							</div>
						</form>
					</div>
				</div>
				<div class="adv align-left">
					<script type="text/javascript"><!--
					google_ad_client = "ca-pub-4975603569119809";
					/* traceip_468x15 */
					google_ad_slot = "6636286518";
					google_ad_width = 468;
					google_ad_height = 15;
					//-->
					</script>
					<script type="text/javascript"
					src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
					</script>
				</div>
	  		</div>
	  		
	  		<hr >
	  		
	  		<div class="row">
	  			<% if (domain != null) { %>
	  				
		  			<div class="span5">
			  			<h4><a href="/out/<%=domain.getDomain()%>"><%=domain.getDomain() %></a></h4>
		  				<p>
		  					<% if (!domain.getIp().isEmpty()) { %>
		  					<%=domain.getDomain() %> has ip address is <%=domain.getIp() %>
		  					<% } else { %>
		  						Can't found Ip Address for <%=domain.getDomain() %>
		  					<% } %>
		  				</p>
		  				
		  				<% if (ipAddress != null) { %>
		  				<h4>Ip Location</h4>
		  				<dl class="attributes clearfix">
							<dt>Country Code:</dt>
							<dd><%=ipAddress.getCountryCode() %></dd>
							<dt>Country Code3:</dt>
							<dd><%=ipAddress.getCountryCode3() %></dd>
							<dt>Country Name:</dt>
							<dd>
								<%=ipAddress.getCountryName() %>
							</dd>
							<dt>City:</dt>
							<dd><%=ipAddress.getCity() %></dd>
							<dt>Continent Code:</dt>
							<dd><%=ipAddress.getContinentCode() %></dd>
							<dt>Latitude:</dt>
							<dd><%=ipAddress.getLatitude() %></dd>
							<dt>Longitude:</dt>
							<dd><%=ipAddress.getLongitude() %></dd>
						</dl>
						<% } %>
						
						<div class="adv align-left">
							<script type="text/javascript"><!--
							google_ad_client = "ca-pub-4975603569119809";
							/* traceip_234x60 */
							google_ad_slot = "5019952514";
							google_ad_width = 234;
							google_ad_height = 60;
							//-->
							</script>
							<script type="text/javascript"
							src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
							</script>
						</div>
		  			</div>
		  			<div class="span4">
		  				<img src="http://maps.google.com/maps/api/staticmap?sensor=false&size=300x300&markers=size:mid|color:blue|label:1|<%=ipAddress.getLatitude() %>,<%=ipAddress.getLongitude() %>&markers=color:black|label:0|<%=ipAddress.getLatitude() %>,<%=ipAddress.getLongitude() %>">
		  			</div>
	  				
	  			<% } else { %>
	  			<div class="span5">
	  				<% if (name.isEmpty()) { %>
	  				<h4>Please enter your domain.</h4>
	  				<% } else { %>
	  				<h4><%=name %> is not valid domain</h4>
	  				<% } %>
	  				<br />
	  				<div class="adv align-left">
	  					<script type="text/javascript"><!--
						google_ad_client = "ca-pub-4975603569119809";
						/* traceip_200x200 */
						google_ad_slot = "9450152116";
						google_ad_width = 200;
						google_ad_height = 200;
						//-->
						</script>
						<script type="text/javascript"
						src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
						</script>
	  				</div>
	  			</div>
	  			<div class="span4">
	  				<script type="text/javascript"><!--
					google_ad_client = "ca-pub-4975603569119809";
					/* traceip_250x250 */
					google_ad_slot = "1926885314";
					google_ad_width = 250;
					google_ad_height = 250;
					//-->
					</script>
					<script type="text/javascript"
					src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
					</script>
	  			</div>
	  			<% } %>
	  		</div>
	  		
	  		<hr >
			
			<% if (domainIp != null) { %>
			<div class="same-domain">
				<div class="adv">
					<script type="text/javascript"><!--
					google_ad_client = "ca-pub-4975603569119809";
					/* traceip_468x60 */
					google_ad_slot = "6496685710";
					google_ad_width = 468;
					google_ad_height = 60;
					//-->
					</script>
					<script type="text/javascript"
					src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
					</script>
				</div>
				<h4>Site same Ip Address <%=domainIp.getIp() %></h4>
				<ul class="list-domain clearfix">
					<%
					for (String dname : domainIp.getDomains()) {
					%>
	          		<li><a href="/domain/<%=dname%>"><%=dname %></a></li>
	          		<% } %>
	          	</ul>
			</div>
			<% } %>
			
		</div>
  		<jsp:include page="/elements/right.jsp" />
	</div>
	    
<jsp:include page="/layouts/footer.jsp" />